﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;

namespace FileParser
{
    public class FileEnumerator<TRecordType> : IEnumerator<TRecordType>
    {
        private readonly string _fileName;
        private readonly FileParserBase<TRecordType>.BuildRecordDeleage _buildRecord;
        private readonly char _splitter;
        private FileStream _fileStream;
        private StreamReader _streamReader;
        private string _currentRow;

        public FileEnumerator(string fileName, FileParserBase<TRecordType>.BuildRecordDeleage buildRecord, char splitter)
        {
            _fileName = fileName;
            _buildRecord = buildRecord;
            _splitter = splitter;

            //
        }

        public void Dispose()
        {
            _streamReader.Dispose();
            _fileStream.Dispose();
        }

        public bool MoveNext()
        {
            throw new System.NotImplementedException();
        }

        public void Reset()
        {
            throw new System.NotImplementedException();
        }

        public TRecordType Current
        {
            get
            {
                string[] strings = _currentRow.Split(_splitter);
                return _buildRecord(strings);
            }
        }

        object IEnumerator.Current
        {
            get { return Current; }
        }
    }
}